package com.njupt.yanglonglong.report.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njupt.yanglonglong.report.demo.dto.StudentExperimentInfo;
import com.njupt.yanglonglong.report.demo.entity.Experiment;
import com.njupt.yanglonglong.report.demo.mapper.ExperimentMapper;
import com.njupt.yanglonglong.report.demo.service.ExperimentService;
import com.njupt.yanglonglong.report.demo.vo.ExperimentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author yangllong
 * @Date 2021/4/28 14:33
 */
@Service
public class ExperimentServiceImpl extends ServiceImpl<ExperimentMapper, Experiment>
        implements ExperimentService {

    @Autowired
    private ExperimentMapper experimentMapper;

    @Override
    public List<ExperimentVO> queryExperiment() {
        return experimentMapper.queryExperiment();
    }

    @Override
    public void uploadReportTemplate(Experiment experiment) {
        experimentMapper.uploadReportTemplate(experiment);
    }

    @Override
    public void deleteReportTemplate(Experiment experiment) {
        experiment.setReportTemplate(null);
        experiment.setTemplateName(null);
        experimentMapper.updateById(experiment);
    }

    @Override
    public List<Experiment> getExperimentListByCourseId(String courseId) {
        QueryWrapper qw = new QueryWrapper();
        qw.eq("course_id", courseId);
        return experimentMapper.selectList(qw);
    }

    @Override
    public List<StudentExperimentInfo> queryStudentExperimentList(String courseId, String stuId) {
        return experimentMapper.queryStudentExperiment(courseId, stuId);
    }
}
